package com.wanmait.myhouse.webController;

import com.wanmait.myhouse.dao.CityDaO;
import com.wanmait.myhouse.dao.HouseDAO;
import com.wanmait.myhouse.dao.RoomDAO;
import com.wanmait.myhouse.dao.TypeDAO;
import com.wanmait.myhouse.vo.City;
import com.wanmait.myhouse.vo.House;
import com.wanmait.myhouse.vo.Room;
import com.wanmait.myhouse.vo.Type;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("web")
public class WebBuyController {
    @GetMapping("buy")
    public String buy(Model model){//城市
        CityDaO cityDaO = new CityDaO();
        List<City> list = cityDaO.FindAll();
        model.addAttribute("list",list);


        //类别
        TypeDAO typeDAO = new TypeDAO();
        List<Type> typelist = typeDAO.FindAll();
        model.addAttribute("typelist",typelist);


        //房间
        RoomDAO roomDAO = new RoomDAO();
        List<Room> roomlist = roomDAO.FindAll();
        model.addAttribute("roomlist",roomlist);

        //查数据库查相关信息
        HouseDAO houseDAO = new HouseDAO();
        List<House> houseList = houseDAO.FindAllInfo(2);
        model.addAttribute("houseList",houseList);

        return "web/buy";
    }
}
